package ${packageName}.utils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import ${packageName}.dto.${className}QueryDTO;
import ${packageName}.entity.${className};
import ${packageName}.vo.${className}Vo;
import com.shoulder.mybatis.utils.PageUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.util.ObjectUtils;

public class ${className}Utils implements PageUtils<${className}, ${className}Vo> {

    public static ${className}Utils buildUtils() {
        return new ${className}Utils();
    }

    @Override
    public ${className}Vo toVo(${className} entity) {
        ${className}Vo vo = new ${className}Vo();
        BeanUtils.copyProperties(entity, vo);
        return vo;
    }
    public static LambdaQueryWrapper<${className}> buildQueryWrapper(${className}QueryDTO queryDTO) {
        LambdaQueryWrapper<${className}> queryWrapper = new LambdaQueryWrapper<${className}>().orderByDesc(${className}::getCreateTime);
        <#list fieldList as field>
        queryWrapper.like(!ObjectUtils.isEmpty(queryDTO.get${field.javaField?cap_first}()), ${className}::get${field.javaField?cap_first}, queryDTO.get${field.javaField?cap_first}());
        </#list>
        return queryWrapper;
    }
}
